<?php require_once('../../Connections/shopcarda1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_product_r = "-1";
if (isset($_GET['p_id'])) {
  $colname_product_r = $_GET['p_id'];
}
mysql_select_db($database_shopcarda1, $shopcarda1);
$query_product_r = sprintf("SELECT * FROM product WHERE p_id = %s", GetSQLValueString($colname_product_r, "int"));
$product_r = mysql_query($query_product_r, $shopcarda1) or die(mysql_error());
$row_product_r = mysql_fetch_assoc($product_r);
$totalRows_product_r = mysql_num_rows($product_r);

mysql_select_db($database_shopcarda1, $shopcarda1);
$query_prod_type_r = "SELECT * FROM prod_type ORDER BY pt_id ASC";
$prod_type_r = mysql_query($query_prod_type_r, $shopcarda1) or die(mysql_error());
$row_prod_type_r = mysql_fetch_assoc($prod_type_r);
$totalRows_prod_type_r = mysql_num_rows($prod_type_r);

mysql_select_db($database_shopcarda1, $shopcarda1);
$query_company_member_r = "SELECT cm_id, company FROM company_member ORDER BY cm_id ASC";
$company_member_r = mysql_query($query_company_member_r, $shopcarda1) or die(mysql_error());
$row_company_member_r = mysql_fetch_assoc($company_member_r);
$totalRows_company_member_r = mysql_num_rows($company_member_r);

$colname_prod_sub_type_r = "-1";
if (isset($_GET['pt_id'])) {
  $colname_prod_sub_type_r = $_GET['pt_id'];
}
mysql_select_db($database_shopcarda1, $shopcarda1);
$query_prod_sub_type_r = sprintf("SELECT * FROM prod_sub_type WHERE type = %s ORDER BY pst_id ASC", GetSQLValueString($colname_prod_sub_type_r, "int"));
$prod_sub_type_r = mysql_query($query_prod_sub_type_r, $shopcarda1) or die(mysql_error());
$row_prod_sub_type_r = mysql_fetch_assoc($prod_sub_type_r);
$totalRows_prod_sub_type_r = mysql_num_rows($prod_sub_type_r);

$colname_type_sub_r = "-1";
if (isset($_GET['pst_id'])) {
  $colname_type_sub_r = $_GET['pst_id'];
}
$colname1_type_sub_r = "-1";
if (isset($_GET['pt_id'])) {
  $colname1_type_sub_r = $_GET['pt_id'];
}
mysql_select_db($database_shopcarda1, $shopcarda1);
$query_type_sub_r = sprintf("SELECT * FROM prod_sub_type WHERE pst_id = %s AND prod_sub_type.type = %s", GetSQLValueString($colname_type_sub_r, "int"),GetSQLValueString($colname1_type_sub_r, "int"));
$type_sub_r = mysql_query($query_type_sub_r, $shopcarda1) or die(mysql_error());
$row_type_sub_r = mysql_fetch_assoc($type_sub_r);
$totalRows_type_sub_r = mysql_num_rows($type_sub_r);

$colname_supplier_brand_r = "-1";
if (isset($_GET['sb_id'])) {
  $colname_supplier_brand_r = $_GET['sb_id'];
}
mysql_select_db($database_shopcarda1, $shopcarda1);
$query_supplier_brand_r = sprintf("SELECT sb_id, cm_id, logo_name FROM supplier_brand WHERE sb_id = %s", GetSQLValueString($colname_supplier_brand_r, "int"));
$supplier_brand_r = mysql_query($query_supplier_brand_r, $shopcarda1) or die(mysql_error());
$row_supplier_brand_r = mysql_fetch_assoc($supplier_brand_r);
$totalRows_supplier_brand_r = mysql_num_rows($supplier_brand_r);

$colname_comp_supplier_r = "-1";
if (isset($_GET['sb_id'])) {
  $colname_comp_supplier_r = $_GET['sb_id'];
}
$colname1_comp_supplier_r = "-1";
if (isset($_GET['cm_id'])) {
  $colname1_comp_supplier_r = $_GET['cm_id'];
}
mysql_select_db($database_shopcarda1, $shopcarda1);
$query_comp_supplier_r = sprintf("SELECT sb_id, cm_id, logo_name FROM supplier_brand WHERE sb_id = %s AND supplier_brand.cm_id = %s", GetSQLValueString($colname_comp_supplier_r, "int"),GetSQLValueString($colname1_comp_supplier_r, "int"));
$comp_supplier_r = mysql_query($query_comp_supplier_r, $shopcarda1) or die(mysql_error());
$row_comp_supplier_r = mysql_fetch_assoc($comp_supplier_r);
$totalRows_comp_supplier_r = mysql_num_rows($comp_supplier_r);


$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

if($_FILES['pic']['tmp_name']!="" && $row_product_r['pic']!=""){
   $files_upload=$_FILES['pic']['tmp_name'];
   // 取得上傳圖片
  
   // 複製上傳圖片到指定 images 目錄
   copy($_FILES['pic']['tmp_name'], "images/" .$row_product_r['pic']); 
   $_POST['pic']=$row_product_r['pic'];
}
//------------------------------------------------
if($_FILES['pic']['tmp_name']!="" && $row_product_r['pic']==""){
   $file_name = $_FILES['pic']['name'];
   //分割檔名
   $fn_array=explode(".",$file_name);
   //檔名
   $mainName = $fn_array[0];
   //副檔名	
   $subName = $fn_array[1];

   $files_upload=$_FILES['pic']['tmp_name'];
   $files_name= (int)(date("YmdHi"))+rand(0,99999);

   // 複製上傳圖片到指定 images 目錄
   copy($_FILES['pic']['tmp_name'], "images/" .$files_name ."." .$subName); 
   $_POST['pic']= $files_name ."." .$subName;
	}
	
if($_FILES['pic']['tmp_name']=="" && $row_product_r['pic']==""){
   $_POST['pic']=$row_product_r['pic'];
}
if($_FILES['pic']['tmp_name']=="" && $row_product_r['pic']!=""){
   $_POST['pic']=$row_product_r['pic'];
}

  $updateSQL = sprintf("UPDATE product SET p_name=%s, sort=%s, sb_id=%s, price=%s, sell_price=%s, sell_mode=%s, pre_year=%s, pre_month=%s, pre_day=%s, ship_month=%s, ship_day=%s, title=%s, pic=%s, prod_txt=%s WHERE p_id=%s",
                       GetSQLValueString($_POST['p_name'], "text"),
                       GetSQLValueString($_POST['sort'], "int"),
                       GetSQLValueString($_POST['sb_id'], "int"),
                       GetSQLValueString($_POST['price'], "int"),
                       GetSQLValueString($_POST['sell_price'], "int"),
                       GetSQLValueString($_POST['sell_mode'], "int"),
                       GetSQLValueString($_POST['pre_year'], "text"),
                       GetSQLValueString($_POST['pre_month'], "text"),
                       GetSQLValueString($_POST['pre_day'], "text"),
                       GetSQLValueString($_POST['ship_month'], "text"),
                       GetSQLValueString($_POST['ship_day'], "text"),
                       GetSQLValueString($_POST['title'], "text"),
                       GetSQLValueString($_POST['pic'], "text"),
                       GetSQLValueString($_POST['prod_txt'], "text"),
                       GetSQLValueString($_POST['p_id'], "int"));

  mysql_select_db($database_shopcarda1, $shopcarda1);
  $Result1 = mysql_query($updateSQL, $shopcarda1) or die(mysql_error());

  $updateGoTo = "admin_product_change_list.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin_page.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>無標題文件</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
#cantainer {
	width: 955px;
	margin-right: 33px;
	margin-left: 33px;
}
#header {
	width: 955px;
	margin-bottom: 10px;
	background-image: url(../../images/top_bg.png);
	height: 82px;
}
#body {
	width: 955px;
	margin-bottom: 10px;
}
#footer {
	width: 955px;
}
.style2 {color: #666666;
	font-size: 12px;
}
#contant_list {
	float: left;
	width: 180px;
	margin-right: 10px;
}
.style17 {color: #74B9E5; font-size: 14px; }
.style43 {font-size: 12px; color: #666666; font-weight: bold; }
#contant_body {
	float: right;
	width: 765px;
}
-->
</style>
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
#contant_body_header {
	width: 765px;
	margin-bottom: 10px;
	background-image: url(../images/admin_product_change_in.png);
	height: 62px;
}
#contant_body_contant {
	width: 765px;
	margin-bottom: 10px;
}
#contant_body_1 {
	background-image: url(../images/admin_product_add.png);
	width: 737px;
	margin-right: 10px;
	margin-left: 10px;
	height: 25px;
	margin-bottom: 10px;
}
#contant_body_2 {
	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}
#contant_body_3 {
	height: 25px;
	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
	background-image: url(../images/admin_product_infor.png);
}
#contant_body_4 {
	width: 737px;
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}
.style44 {color: #000000}
#contant_body_5 {
	width: 737px;
	margin-right: 10px;
	margin-left: 10px;
	margin-bottom: 10px;
}
.style50 {
	font-size: 9px;
	color: #FF0000;
}
-->
</style>
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/selectboxes.js"></script>
<script type="text/javascript" src="../js/prod3.js"></script>
<script type="text/javascript" src="../js/prod4.js"></script>
<!-- InstanceEndEditable -->
</head>

<body>
<table width="1024" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div id="cantainer">
      <div id="header"></div>
      <div id="body">
        <div id="contant_list">
          <table border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td align="center"><img src="../../images/index_12.png" width="180" height="54" /></td>
            </tr>
            <tr>
              <td><table width="180" border="0" align="center" cellpadding="0" cellspacing="0" background="../../images/index_12_20.png">
                  <tr>
                    <td width="10"></td>
                    <td><table border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left" class="style43">商品管理</td>
                        </tr>
                        <tr>
                          <td width="30" align="center">&nbsp;</td>
                          <td width="127" align="left" class="style2"><a href="admin_product_add.html">新增商品</a><br />
                            <a href="admin_product_change_list.html">產品資訊管理</a><br /></td>
                        </tr>
                        <tr>
                          <td colspan="2"><img src="../../images/dotsline.png" width="167" height="11" /></td>
                        </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left"><strong class="style43">會員管理</strong></td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                          <td align="left" class="style2"><a href="../member/company_member/admin_companym_add.html">新增公司會員</a><br />
                            <a href="../member/company_member/admin_companym_list.html">公司會員管理</a><br />
                            <a href="../member/personal_member/admin_pearsonal_list.html">個人會員管理</a></td>
                        </tr>
                        <tr>
                          <td colspan="2"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                        </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left" class="style43">供應商管理</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                          <td align="left" class="style2"><a href="../supplier/admin_supplier_brand.html">品牌管理</a></td>
                        </tr>
                        <tr>
                          <td colspan="2"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                        </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left" class="style43">進銷存管理</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                          <td align="left" class="style2">進貨管理<br />
                            訂單管理</td>
                        </tr>
                        <tr>
                          <td colspan="2" align="center"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                          </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left" class="style43">紅利管理</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                          <td align="left" class="style2">紅利設定<br />
                            公司會員紅利管理<br />
                            個人會員紅利管理</td>
                        </tr>
                        <tr>
                          <td colspan="2" align="center"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                        </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td align="left" class="style43">資訊管理</td>
                        </tr>
                        <tr>
                          <td align="center">&nbsp;</td>
                          <td align="left" class="style2">公告資訊管理<br />
                            公司資訊管理<br />
                            客服資訊管理<br />
                            Banner管理</td>
                        </tr>
                        <tr>
                          <td colspan="2"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                        </tr>
                        <tr>
                          <td align="center"><span class="style17">＞</span></td>
                          <td class="style43">權限管理</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td class="style2">新增使用者<br />
                            使用者設定<br />
                            群組設定<br />
                            使用者權限設定</td>
                        </tr>
                        <tr>
                          <td colspan="2"><img src="../../images/dotsline.png" alt="" width="167" height="11" /></td>
                        </tr>
                    </table></td>
                    <td width="10"></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td width="180" height="28" align="center"><table width="0" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="180" height="28" align="center"><img src="../../images/index_20.png" width="180" height="28" /></td>
                  </tr>
              </table></td>
            </tr>
          </table>
        </div>
        <!-- InstanceBeginEditable name="EditRegion1" -->
        <form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>">
        <div id="contant_body">
          <div id="contant_body_header"></div>
          <div id="contant_body_contant">
            <table cellpadding="0" cellspacing="0">
              <tr>
                <td colspan="3"><img src="../../member/img/member_body_up.jpg" width="765" height="9" /></td>
              </tr>
              <tr>
                <td width="4" background="../../member/img/member_body_left.jpg">&nbsp;</td>
                <td width="757"><div id="contant_body_1"></div>
                  <div id="contant_body_2">
                    <table width="737" cellpadding="5" cellspacing="0">
                      <tr>
                        <td align="left" class="style2 style44">商品貨號</td>
                        <td colspan="3" class="style2 style44">NI<?php echo $row_product_r['p_id']; ?>
                          <input name="p_id" type="hidden" id="p_id" value="<?php echo $row_product_r['p_id']; ?>" /></td>
                      </tr>
                      <tr>
                        <td align="left" bgcolor="#E2F8F6" class="style2 style44">商品原始貨號</td>
                        <td colspan="3" bgcolor="#E2F8F6" class="style2"><?php echo $row_product_r['prod_no']; ?></td>
                      </tr>
                      <tr>
                        <td width="120" align="left" class="style2 style44">商品名稱</td>
                        <td colspan="3" class="style2">
                          <label>
                          <input name="p_name" type="text" id="p_name" value="<?php echo $row_product_r['p_name']; ?>" size="30" />
                          </label>                       </td>
                      </tr>
                      
                      <tr>
                        <td align="left" bgcolor="#E2F8F6" class="style2 style44">商品類別</td>
                        <td width="116" bgcolor="#E2F8F6" class="style2">
                          <label>
                            <select name="select1" id="select1">
                              <?php
do {  
?>
                              <option value="<?php echo $row_prod_type_r['pt_id']?>"<?php if (!(strcmp($row_prod_type_r['pt_id'], $_GET['pt_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_prod_type_r['type']?></option>
                              <?php
} while ($row_prod_type_r = mysql_fetch_assoc($prod_type_r));
  $rows = mysql_num_rows($prod_type_r);
  if($rows > 0) {
      mysql_data_seek($prod_type_r, 0);
	  $row_prod_type_r = mysql_fetch_assoc($prod_type_r);
  }
?>
                            </select>
                            </label>                      </td>
                        <td width="118" bgcolor="#E2F8F6" class="style2">
                          <label>
                            <select name="sort" id="sort">
                              <?php
do {  
?>
                              <option value="<?php echo $row_prod_sub_type_r['pst_id']?>"<?php if (!(strcmp($row_prod_sub_type_r['pst_id'], $_GET['pst_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_prod_sub_type_r['sub_type']?></option>
                              <?php
} while ($row_prod_sub_type_r = mysql_fetch_assoc($prod_sub_type_r));
  $rows = mysql_num_rows($prod_sub_type_r);
  if($rows > 0) {
      mysql_data_seek($prod_sub_type_r, 0);
	  $row_prod_sub_type_r = mysql_fetch_assoc($prod_sub_type_r);
  }
?>
                            </select>
                            </label>                    </td>
                        <td width="341" bgcolor="#E2F8F6" class="style2 style44"><input id="fullIdPath" type="hidden" value="<?php echo $row_type_sub_r['type']; ?>,<?php echo $row_type_sub_r['pst_id']; ?>" /></td>
                      </tr>
                      <tr>
                        <td align="left" class="style2 style44">製造商</td>
                        <td colspan="3" class="style2 style44">
                          <label>
                            <select name="select2" id="select2">
                              <?php
do {  
?>
                              <option value="<?php echo $row_company_member_r['cm_id']?>"<?php if (!(strcmp($row_company_member_r['cm_id'], $_GET['cm_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_company_member_r['company']?></option>
                              <?php
} while ($row_company_member_r = mysql_fetch_assoc($company_member_r));
  $rows = mysql_num_rows($company_member_r);
  if($rows > 0) {
      mysql_data_seek($company_member_r, 0);
	  $row_company_member_r = mysql_fetch_assoc($company_member_r);
  }
?>
                            </select>
                            </label>
                          <label>
                          <select name="sb_id" id="sb_id">
                            <?php
do {  
?>
                            <option value="<?php echo $row_supplier_brand_r['sb_id']?>"<?php if (!(strcmp($row_supplier_brand_r['sb_id'], $_GET['sb_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_supplier_brand_r['logo_name']?></option>
                            <?php
} while ($row_supplier_brand_r = mysql_fetch_assoc($supplier_brand_r));
  $rows = mysql_num_rows($supplier_brand_r);
  if($rows > 0) {
      mysql_data_seek($supplier_brand_r, 0);
	  $row_supplier_brand_r = mysql_fetch_assoc($supplier_brand_r);
  }
?>
                          </select>
                          </label>                        <label>
                            <input id="fullIdPath1" type="hidden" value="<?php echo $row_comp_supplier_r['cm_id']; ?>,<?php echo $row_comp_supplier_r['sb_id']; ?>" />
                          </label></td>
                      </tr>
                      <tr>
                        <td align="left" bgcolor="#E2F8F6" class="style2 style44">訂價</td>
                        <td colspan="3" bgcolor="#E2F8F6" class="style2">
                          <label>
                            <input name="price" type="text" id="price" value="<?php echo $row_product_r['price']; ?>" size="15" />
                            </label>                      </td>
                      </tr>
                      <tr>
                        <td align="left" class="style2 style44">售價</td>
                        <td colspan="3" class="style2">
                            <label>
                              <input name="sell_price" type="text" id="sell_price" value="<?php echo $row_product_r['sell_price']; ?>" size="15" />
                              </label>                    </td>
                      </tr>
                      <tr>
                        <td align="left" bgcolor="#E2F8F6" class="style2 style44">販售方式</td>
                        <td colspan="3" bgcolor="#E2F8F6" class="style2">
                          <label>
                              <input <?php if (!(strcmp($row_product_r['sell_mode'],"1"))) {echo "checked=\"checked\"";} ?> name="sell_mode" type="radio" id="sell_mode_0" value="1" />
                              正品</label>
                            <label>
                              <input <?php if (!(strcmp($row_product_r['sell_mode'],"2"))) {echo "checked=\"checked\"";} ?> type="radio" name="sell_mode" value="2" id="sell_mode_1" />
                              特價</label>
                            <label>
                              <input <?php if (!(strcmp($row_product_r['sell_mode'],"3"))) {echo "checked=\"checked\"";} ?> type="radio" name="sell_mode" value="3" id="sell_mode_2" />
                              預售</label>
                            &nbsp;
                            <label>
                              <input name="pre_year" type="text" id="pre_year" value="<?php echo $row_product_r['pre_year']; ?>" size="4" />
                              年
                              <select name="pre_month" id="pre_month">
                                <option selected="selected" value="" <?php if (!(strcmp("", $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>請選擇</option>
                                <option value="1" <?php if (!(strcmp(1, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>1</option>
                                <option value="2" <?php if (!(strcmp(2, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>2</option>
                                <option value="3" <?php if (!(strcmp(3, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>3</option>
                                <option value="4" <?php if (!(strcmp(4, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>4</option>
                                <option value="5" <?php if (!(strcmp(5, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>5</option>
                                <option value="6" <?php if (!(strcmp(6, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>6</option>
                                <option value="7" <?php if (!(strcmp(7, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>7</option>
                                <option value="8" <?php if (!(strcmp(8, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>8</option>
                                <option value="9" <?php if (!(strcmp(9, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>9</option>
                                <option value="10" <?php if (!(strcmp(10, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>10</option>
                                <option value="11" <?php if (!(strcmp(11, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>11</option>
                                <option value="12" <?php if (!(strcmp(12, $row_product_r['pre_month']))) {echo "selected=\"selected\"";} ?>>12</option>
                                </select>
                              月
                              <select name="pre_day" id="pre_day">
                                <option selected="selected" value="" <?php if (!(strcmp("", $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>請選擇</option>
                                <option value="1" <?php if (!(strcmp(1, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>1</option>
                                <option value="2" <?php if (!(strcmp(2, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>2</option>
                                <option value="3" <?php if (!(strcmp(3, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>3</option>
                                <option value="4" <?php if (!(strcmp(4, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>4</option>
                                <option value="5" <?php if (!(strcmp(5, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>5</option>
                                <option value="6" <?php if (!(strcmp(6, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>6</option>
                                <option value="7" <?php if (!(strcmp(7, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>7</option>
                                <option value="8" <?php if (!(strcmp(8, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>8</option>
                                <option value="9" <?php if (!(strcmp(9, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>9</option>
                                <option value="10" <?php if (!(strcmp(10, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>10</option>
                                <option value="11" <?php if (!(strcmp(11, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>11</option>
                                <option value="12" <?php if (!(strcmp(12, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>12</option>
                                <option value="13" <?php if (!(strcmp(13, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>13</option>
                                <option value="14" <?php if (!(strcmp(14, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>14</option>
                                <option value="15" <?php if (!(strcmp(15, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>15</option>
                                <option value="16" <?php if (!(strcmp(16, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>16</option>
                                <option value="17" <?php if (!(strcmp(17, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>17</option>
                                <option value="18" <?php if (!(strcmp(18, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>18</option>
                                <option value="19" <?php if (!(strcmp(19, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>19</option>
                                <option value="20" <?php if (!(strcmp(20, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>20</option>
                                <option value="21" <?php if (!(strcmp(21, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>21</option>
                                <option value="22" <?php if (!(strcmp(22, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>22</option>
                                <option value="23" <?php if (!(strcmp(23, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>23</option>
                                <option value="24" <?php if (!(strcmp(24, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>24</option>
                                <option value="25" <?php if (!(strcmp(25, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>25</option>
                                <option value="26" <?php if (!(strcmp(26, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>26</option>
                                <option value="27" <?php if (!(strcmp(27, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>27</option>
                                <option value="28" <?php if (!(strcmp(28, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>28</option>
                                <option value="29" <?php if (!(strcmp(29, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>29</option>
                                <option value="30" <?php if (!(strcmp(30, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>30</option>
                                <option value="31" <?php if (!(strcmp(31, $row_product_r['pre_day']))) {echo "selected=\"selected\"";} ?>>31</option>
                                </select>
                            日</label><label>
                              <input <?php if (!(strcmp($row_product_r['sell_mode'],"4"))) {echo "checked=\"checked\"";} ?> name="sell_mode" type="radio" id="sell_mode_4" value="4" />
                            下架</label></td>
                      </tr>
                      <tr>
                        <td align="left" class="style2 style44">出貨時間</td>
                        <td colspan="3" class="style2">
                          <label>
                            <select name="ship_month" id="ship_month">
                              <option selected="selected" value="" <?php if (!(strcmp("", $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>請選擇</option>
                              <option value="1" <?php if (!(strcmp(1, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>1個</option>
                              <option value="2" <?php if (!(strcmp(2, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>2個</option>
                              <option value="3" <?php if (!(strcmp(3, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>3個</option>
                              <option value="4" <?php if (!(strcmp(4, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>4個</option>
                              <option value="5" <?php if (!(strcmp(5, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>5個</option>
                              <option value="6" <?php if (!(strcmp(6, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>6個</option>
                              <option value="7" <?php if (!(strcmp(7, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>7個</option>
<option value="8" <?php if (!(strcmp(8, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>8個</option>
                              <option value="9" <?php if (!(strcmp(9, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>9個</option>
                              <option value="10" <?php if (!(strcmp(10, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>10個</option>
                              <option value="11" <?php if (!(strcmp(11, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>11個</option>
                              <option value="12" <?php if (!(strcmp(12, $row_product_r['ship_month']))) {echo "selected=\"selected\"";} ?>>12個</option>
                            </select>
                            </label>
                          月
                          <label>
                            <select name="ship_day" id="ship_day">
                              <option selected="selected" value="" <?php if (!(strcmp("", $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>請選擇</option>
                              <option value="1" <?php if (!(strcmp(1, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>1</option>
                              <option value="2" <?php if (!(strcmp(2, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>2</option>
                              <option value="3" <?php if (!(strcmp(3, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>3</option>
                              <option value="4" <?php if (!(strcmp(4, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>4</option>
                              <option value="5" <?php if (!(strcmp(5, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>5</option>
                              <option value="6" <?php if (!(strcmp(6, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>6</option>
                              <option value="7" <?php if (!(strcmp(7, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>7</option>
                              <option value="8" <?php if (!(strcmp(8, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>8</option>
                              <option value="9" <?php if (!(strcmp(9, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>9</option>
                              <option value="10" <?php if (!(strcmp(10, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>10</option>
                              <option value="11" <?php if (!(strcmp(11, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>11</option>
                              <option value="12" <?php if (!(strcmp(12, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>12</option>
                              <option value="13" <?php if (!(strcmp(13, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>13</option>
                              <option value="14" <?php if (!(strcmp(14, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>14</option>
                              <option value="15" <?php if (!(strcmp(15, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>15</option>
                              <option value="16" <?php if (!(strcmp(16, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>16</option>
                              <option value="17" <?php if (!(strcmp(17, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>17</option>
                              <option value="18" <?php if (!(strcmp(18, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>18</option>
                              <option value="19" <?php if (!(strcmp(19, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>19</option>
                              <option value="20" <?php if (!(strcmp(20, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>20</option>
                              <option value="21" <?php if (!(strcmp(21, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>21</option>
                              <option value="22" <?php if (!(strcmp(22, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>22</option>
                              <option value="23" <?php if (!(strcmp(23, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>23</option>
                              <option value="24" <?php if (!(strcmp(24, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>24</option>
                              <option value="25" <?php if (!(strcmp(25, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>25</option>
                              <option value="26" <?php if (!(strcmp(26, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>26</option>
                              <option value="27" <?php if (!(strcmp(27, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>27</option>
                              <option value="28" <?php if (!(strcmp(28, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>28</option>
                              <option value="29" <?php if (!(strcmp(29, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>29</option>
                              <option value="30" <?php if (!(strcmp(30, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>30</option>
                              <option value="31" <?php if (!(strcmp(31, $row_product_r['ship_day']))) {echo "selected=\"selected\"";} ?>>31</option>
                            </select>
                            </label>
                          日                      </td>
                      </tr>
                    </table>
                  </div>
                  <div id="contant_body_3"></div>
                  <div id="contant_body_4">
                    <table width="737" cellspacing="0" cellpadding="5">
                      <tr>
                        <td width="120" align="left" valign="top" class="style2 style44">標題</td>
                        <td width="595" class="style2">
                            <label>
                            <textarea name="title" id="title" cols="45" rows="2"><?php echo $row_product_r['title']; ?></textarea>
                            </label>
                        </td>
                      </tr>
                      <tr bgcolor="#E2F8F6">
                        <td align="left" valign="top" class="style2 style44">小圖上傳</td>
                        <td class="style2"><table width="100%" cellspacing="0" cellpadding="5">
                            <tr>
                              <td width="37%" class="style44">
                                  <label>
                                  <input name="pic" type="file" id="pic" size="30" />
                                  </label>
                              </td>
                              <td width="9%" align="center" class="style44">
                                  <?php if ($row_product_r['pic']!="") { // Show if recordset not empty ?>
                                  <label>
                                  <input type="button" name="button6" id="button6" value="預覽" onclick="openWinPic('<?php echo $row_product_r['pic']; ?>')" />
                                  </label>
                                    <?php } // Show if recordset not empty ?>
                              </td>
                              <td width="40%" class="style44">1:1</td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top" class="style2 style44">介紹內容</td>
                        <td class="style2">
                            <label>
                            <textarea name="prod_txt" id="prod_txt" cols="65" rows="20"><?php echo $row_product_r['prod_txt']; ?></textarea>
                            </label>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <div id="contant_body_5">
                    <table width="100%" cellspacing="0" cellpadding="0">
                      <tr>
                        <td align="center">
                          <label>
                            <input type="submit" name="button7" id="button7" value="修改" />
                            <input type="submit" name="button9" id="button9" value="回上一頁" />
                            </label>
                          <label>
                          <input type="submit" name="button8" id="button8" value="重填" />
                          </label>
                        </td>
                      </tr>
                    </table>
                  </div></td>
                <td width="4" background="../../member/img/member_body_right.jpg">&nbsp;</td>
              </tr>
              <tr>
                <td height="9" colspan="3"><img src="../../member/img/member_body_down.jpg" width="765" height="9" /></td>
              </tr>
            </table>
          </div>
        </div>
        <input type="hidden" name="MM_update" value="form1" />
        </form>
        <?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("prod_txt");
?>
<script>

function openWinPic(pic){
      var printPage = window.open("","printPage","");
      printPage.document.open();
      printPage.document.write("<HTML><head>");
	  printPage.document.write("</head><BODY>");
	  printPage.document.write("<PRE>");
	  printPage.document.write('<table border="0" align="center">');
	  printPage.document.write('<tr><td height="21" align="center"><input type="button" value="關閉" onclick="window.close();"></td></tr>');
	  printPage.document.write('<tr><td>');
      printPage.document.write('<img src="images/'+pic);
	  printPage.document.write('" />');
	  printPage.document.write('</td></tr></table>');
      printPage.document.write("</PRE>");
      printPage.document.close("</BODY></HTML>");
	  
}

</script>
        <!-- InstanceEndEditable --></div>
      <div id="footer">
        <table width="955" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="230" height="118" align="center"><a href="index.html"><img width="200" height="66" alt="logo位置" style="background-color: #FF0000" /></a></td>
            <td width="10" align="center"><img src="../../images/end_Separateline1.png" width="1" height="80" /></td>
            <td width="715" valign="middle"><table width="715" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="40" valign="top" class="style2"><table border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="50" align="center" class="style2"></td>
                        <td>本平台中台灣各店家所銷售的商品或服務，都是由各該店家所銷售或提供。 | 電話 : 02-2275-3588 | 傳真 : 02-2275-3788<br/>
                          微衡科技　版權所有 ⓒ 2011 Microbalance. All Rights Reserved.</td>
                      </tr>
                  </table></td>
                </tr>
            </table></td>
          </tr>
        </table>
      </div>
      </div></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($product_r);

mysql_free_result($prod_type_r);

mysql_free_result($company_member_r);

mysql_free_result($prod_sub_type_r);

mysql_free_result($type_sub_r);

mysql_free_result($supplier_brand_r);

mysql_free_result($comp_supplier_r);
?>
